package com.rgp.servicemap.controller;

import com.rgp.internalcommon.dto.ResponseResult;
import com.rgp.internalcommon.dto.TrackPointsDto;
import com.rgp.internalcommon.dto.TrackRequestDto;
import com.rgp.internalcommon.response.TrackResponse;
import com.rgp.internalcommon.response.TrsearchResponse;
import com.rgp.servicemap.service.TrackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author nhp
 * @version 1.0
 * @description TODO
 * @date 2024-04-19 20:04
 */
@RestController
public class TrackController {

    @Autowired
    private TrackService trackService;

    @PostMapping("track/add")
    public ResponseResult<TrackResponse> addTrack(@RequestParam("tid") Long tid){
        return trackService.addTrack(tid);
    }

    @DeleteMapping("track/delete")
    public ResponseResult deleteTrack(@RequestBody TrackRequestDto trackRequestDto){
        return trackService.deleteTrack(trackRequestDto);
    }

    @PostMapping("track-point/upload")
    public ResponseResult uploadTrackPoints(@RequestBody TrackPointsDto trackPointsDto){
        return trackService.upload(trackPointsDto);
    }

    @GetMapping("track/terminal/trsearch")
    public ResponseResult<TrsearchResponse> trsearch(@RequestParam("tid") Long tid,
                                                     @RequestParam("trid") Integer trid,
                                                     @RequestParam("startTime") String startTime,
                                                     @RequestParam("endTime") String endTime){
        return trackService.trsearch(tid,trid,startTime,endTime);
    }
}
